import React from 'react';
//  获取rtk仓库中的数据并修改rtk仓库数据
import { useSelector, useDispatch } from 'react-redux';
// 导入修改state 数据reducer 中的方法
import { addAge, editname } from '../../store-rtk/index';

const Father = () => {

    // 获取store 数据
    const state = useSelector(state => state);
    const dispatch = useDispatch();

    console.log('state', state);
    return (
        <div>
            <p>store 仓库中的数据: {state.name}--{state.age}</p>
            <p>
                <button onClick={() => dispatch(addAge())}>修改年龄</button>
                <button onClick={() => dispatch(editname('谢广坤'))}>修改姓名</button>
            </p>
        </div>
    );
}

export default Father;
